﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace SPI_TOOLS.ViewModels
{
    public class MainViewModel:ViewModelBase
    {
        private ObservableCollection<string> operatorLog = new ObservableCollection<string>();
        public ObservableCollection<string> OperatorLog
        {
            get { return operatorLog; }
            set { operatorLog = value; RaisePropertyChanged(nameof(OperatorLog)); }
        }
        public MainViewModel() 
        {
            Messenger.Default.Register<string>(this, "operator_log", new Action<string>((msg) => 
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    OperatorLog.Add($"{DateTime.Now}=>{msg}");
                });
            }));
        }
    }
}
